{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Working on a Windows 10\n", "Python version 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:40:50) [MSC v.1937 64 bit (AMD64)]\n", "Pandas version 2.2.3\n", "bifacial_radiance version 0.5.0b2.dev4+gedb973d.d20250924\n" ] } ], "source": [ "# This information helps with debugging and getting support :)\n", "import sys, platform\n", "import pandas as pd\n", "import bifacial_radiance as br\n", "print(\"Working on a \", platform.system(), platform.release())\n", "print(\"Python version \", sys.version)\n", "print(\"Pandas version \", pd.__version__)\n", "print(\"bifacial_radiance version \", br.__version__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 7 - Multiple Scene Objects\n", "\n", "This journal shows how to:\n", "\n", "* Create multiple scene objects in the same scene.\n", "* Analyze multiple scene objects in the same scene \n", "* Add a marker to find the origin (0,0) on a scene (for sanity-checks/visualization).\n", "\n", "A scene Object is defined as an array of modules, with whatever parameters you want to give it. In this case, we are modeling one array of 2 rows of 5 modules in landscape, and one array of 1 row of 5 modules in 2-UP, portrait configuration, as the image below:\n", "\n", "\n", "\n", "\n", "### Steps:\n", "\n", "1. Generating the setups\n", " 1. Generating the firt scene object\n", " 2. Generating the second scene object.\n", "2. Add a Marker at the Origin (coordinates 0,0) for help with visualization \n", "3. Combine all scene Objects into one OCT file & Visualize \n", "4. Analysis for Each sceneObject " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Generating the Setups" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Your simulation will be stored in C:\\Users\\cdeline\\Documents\\Python Scripts\\Bifacial_Radiance\\bifacial_radiance\\TEMP\\Tutorial_07\n" ] } ], "source": [ "import os\n", "import numpy as np\n", "import pandas as pd\n", "from pathlib import Path\n", "\n", "testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_07')\n", "if not os.path.exists(testfolder):\n", " os.makedirs(testfolder)\n", " \n", "print (\"Your simulation will be stored in %s\" % testfolder)\n", " \n", "from bifacial_radiance import RadianceObj, AnalysisObj " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### A. Generating the first scene object\n", "\n", "This is a standard fixed-tilt setup for one hour. Gencumsky could be used too for the whole year.\n", "\n", "The key here is that we are setting in sceneDict the variable **appendRadfile** to true." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "path = C:\\Users\\cdeline\\Documents\\Python Scripts\\Bifacial_Radiance\\bifacial_radiance\\TEMP\\Tutorial_07\n", "Loading albedo, 1 value(s), 0.620 avg\n", "1 nonzero albedo values.\n", "Getting weather file: USA_VA_Richmond.724010_TMY2.epw\n", " ... OK!\n", "8760 line in WeatherFile. Assuming this is a standard hourly WeatherFile for the year for purposes of saving Gencumulativesky temporary weather files in EPW folder.\n", "Coercing year to 2001\n", "Saving file EPWs\\metdata_temp.csv, # points: 8760\n", "Calculating Sun position for Metdata that is right-labeled with a delta of -30 mins. i.e. 12 is 11:30 sunpos\n", "\n", "Module Name: test-moduleA\n", "Module test-moduleA updated in module.json\n", "Pre-existing .rad file objects\\test-moduleA.rad will be overwritten\n", "\n" ] } ], "source": [ "demo = RadianceObj(\"tutorial_7\", path = testfolder) \n", "demo.setGround(0.62)\n", "epwfile = demo.getEPW(lat = 37.5, lon = -77.6) \n", "metdata = demo.readWeatherFile(epwfile, coerce_year=2001) \n", "fullYear = True\n", "timestamp = metdata.datetime.index(pd.to_datetime('2001-06-17 13:0:0 -5')) # Noon, June 17th \n", "demo.gendaylit(timestamp) \n", "module_type = 'test-moduleA' \n", "mymodule = demo.makeModule(name=module_type,y=1,x=1.7)\n", "sceneDict = {'tilt':10,'pitch':1.5,'clearance_height':0.2,'azimuth':180, 'nMods': 5, 'nRows': 2} \n", "sceneObj1 = demo.makeScene(mymodule, sceneDict) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Checking values after Scene for the scene Object created" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SceneObj1 modulefile: objects\\test-moduleA.rad\n", "SceneObj1 SceneFile: ['objects\\\\test-moduleA_C_0.20_rtr_1.50_tilt_10_5modsx2rows_origin0,0.rad']\n", "SceneObj1 GCR: 0.67\n", "FileLists: \n", " ['materials\\\\ground.rad', 'skies\\\\sky2_37.5_-77.33_2001-06-17_1300.rad', 'objects\\\\test-moduleA_C_0.20_rtr_1.50_tilt_10_5modsx2rows_origin0,0.rad']\n" ] } ], "source": [ "print (\"SceneObj1 modulefile: %s\" % sceneObj1.modulefile)\n", "print (\"SceneObj1 SceneFile: %s\" %sceneObj1.radfiles)\n", "print (\"SceneObj1 GCR: %s\" % round(sceneObj1.gcr,2))\n", "print (\"FileLists: \\n %s\" % demo.getfilelist())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### B. Generating the second scene object.\n", "\n", "Creating a different Scene. Same Module, different values.\n", "Notice we are passing a different **originx** and **originy** to displace the center of this new sceneObj to that location.\n", "\n", "To make this work, we **need** to use `append=True`. Otherwise the second scene will overwrite the first.\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Module Name: test-moduleB\n", "Module test-moduleB updated in module.json\n", "Pre-existing .rad file objects\\test-moduleB.rad will be overwritten\n", "\n", "Additional scene Scene1 created! See list of names with RadianceObj.scenes and sceneNames\n" ] }, { "data": { "text/plain": [ "['Scene0', 'Scene1']" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sceneDict2 = {'tilt':30,'pitch':5,'clearance_height':1,'azimuth':180, \n", " 'nMods': 5, 'nRows': 1, 'originx': 0, 'originy': 3.5, 'appendRadfile':True} \n", "module_type2='test-moduleB'\n", "mymodule2 = demo.makeModule(name=module_type2,x=1,y=1.6, numpanels=2, ygap=0.15)\n", "sceneObj2 = demo.makeScene(mymodule2, sceneDict2, append=True) \n", "\n", "demo.sceneNames()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SceneObj1 modulefile: objects\\test-moduleA.rad\n", "SceneObj1 SceneFile: ['objects\\\\test-moduleA_C_0.20_rtr_1.50_tilt_10_5modsx2rows_origin0,0.rad']\n", "SceneObj1 GCR: 0.67\n", "\n", "SceneObj2 modulefile: objects\\test-moduleB.rad\n", "SceneObj2 SceneFile: ['objects\\\\test-moduleB_C_1.00_rtr_5.00_tilt_30_5modsx1rows_origin0,3.5.rad']\n", "SceneObj2 GCR: 0.67\n", "NEW FileLists: \n", " ['materials\\\\ground.rad', 'skies\\\\sky2_37.5_-77.33_2001-06-17_1300.rad', 'objects\\\\test-moduleA_C_0.20_rtr_1.50_tilt_10_5modsx2rows_origin0,0.rad', 'objects\\\\test-moduleB_C_1.00_rtr_5.00_tilt_30_5modsx1rows_origin0,3.5.rad']\n" ] } ], "source": [ "# Checking values for both scenes after creating new SceneObj\n", "print (\"SceneObj1 modulefile: %s\" % sceneObj1.modulefile)\n", "print (\"SceneObj1 SceneFile: %s\" %sceneObj1.radfiles)\n", "print (\"SceneObj1 GCR: %s\" % round(sceneObj1.gcr,2))\n", "\n", "print (\"\\nSceneObj2 modulefile: %s\" % sceneObj2.modulefile)\n", "print (\"SceneObj2 SceneFile: %s\" %sceneObj2.radfiles)\n", "print (\"SceneObj2 GCR: %s\" % round(sceneObj2.gcr,2))\n", "\n", "#getfilelist should have info for the rad file created by BOTH scene objects.\n", "print (\"NEW FileLists: \\n %s\" % demo.getfilelist())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Add a Marker at the Origin (coordinates 0,0) for help with visualization\n", "\n", "Creating a \"markers\" for the geometry is useful to orient one-self when doing sanity-checks (for example, marke where 0,0 is, or where 5,0 coordinate is).\n", "\n", "